package com.codingfuture.erp_system.service.impl;

import com.codingfuture.erp_system.entity.Store;
import com.codingfuture.erp_system.mapper.StoreMapper;
import com.codingfuture.erp_system.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StoreServiceImpl implements StoreService {

    @Autowired
    private StoreMapper storeMapper;

    @Override
    public Store findById(Integer id) {
        return storeMapper.findById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean insertStore(String name, Integer empuuid) {
        return storeMapper.insertStore(name, empuuid) != 0;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteStore(Integer id) {
        return storeMapper.deleteStore(id) != 0;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateStore(Store store) {
        return storeMapper.updateStore(store) != 0;
    }

    @Override
    public List<Store> findByAll() {
        return null;
    }

    @Override
    public List<Store> findByAll(Store store) {
        return storeMapper.findByAll(store);
    }

    @Override
    public Store nameExist(String name) {
        return storeMapper.nameExist(name);
    }

    @Override
    public Store uuidExist(Integer empuuid) {
        return storeMapper.uuidExist(empuuid);
    }


    @Override
    public List<Store> findByName(String name) {
        List<Store> list = storeMapper.findByName(name);
        return list;
    }


}
